﻿using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Data.SqlClient;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
using System.Threading;
using System.Globalization;
using Nivdal.AuxCode;

namespace Nivdal
{
    public partial class TeamListOfPlayers : System.Web.UI.Page
    {
        string TeamId = null;
        protected void Page_Load(object sender, EventArgs e)
        {
            String TeamName;
            bool IsNational;
            
            GetNivdalData.GetNivdalData GND = new GetNivdalData.GetNivdalData();
            OnlineUser ou = (OnlineUser)Session["User"];
            string UsrId = ou.UserId;
            
            if (Request.QueryString["TeamId"] != null)
                TeamId = Request.QueryString["TeamId"].ToString();
            else
            {
                if (Request.QueryString["NationalTeam"] != null)
                    TeamId = ou.NationalTeamCoach;
                else
                    TeamId = ou.TeamId;
            }

            if (TeamId == null)
                Response.Redirect("~/Default.aspx");

            if (Request.QueryString["NationalTeam"] != null)
            {
                // chaning data binding to National team
                TeamListOfPlayersSqlDataSource.SelectCommand = "Nivdal_NTGetListOfNationalTeamPlayers";
                IsNationalHiddenField.Value = "yes";
                IsNational = true;
            }
            else
            {
                IsNational = false;
                IsNationalHiddenField.Value = "no";
            }

            string NumPlayers = GND.ReadNivdalStringData("TeamId", "IsNational", "Nivdal_GetNumberOfTeamPlayers", TeamId, IsNational ? "1" : "0");

            if (!IsPostBack)
            {
                string TeamIdParamName = IsNational ? "NTTeamId" : "TeamId";
                this.TeamListOfPlayersSqlDataSource.SelectParameters.Add(TeamIdParamName, TeamId);
                this.TeamListOfPlayersSqlDataSource.SelectParameters.Add("Language", ou.Language);
                
            }
            if (IsNational)
                this.TeamHyperLink.NavigateUrl = "NationalTeam.aspx?Id=" + TeamId + "&National=yes";
            else
                this.TeamHyperLink.NavigateUrl = "TeamHomePage.aspx?TeamId=" + TeamId;

            TeamName = (GND.ReadNivdalStringData("@TeamId", "IsNational", "Nivdal_GetTeamNameByTeamId", TeamId, IsNational ? "1" : "0"));
            this.TeamHyperLink.Text = TeamName;
            this.NumberOfPlayersLabel.Text = NumPlayers + " " + Resources.Resource.TeamListOfPlayers_playersOf + " " + TeamName;
            this.Title = Resources.Resource.Default_PageTitle + ", " + Resources.Resource.Global_Players + ": " + TeamName;
            //this.Title = TeamName + " " + Resources.Resource.Global_Players + " - nivdal.com!";

            if ((NumPlayers != "0") && (SummaryGridview.HeaderRow != null))
                SummaryGridview.HeaderRow.TableSection = TableRowSection.TableHeader;

            if ((TeamId != ou.TeamId) && (!IsNational))
            {
                IsTeamOwnerHiddenField.Value = "false";
            }
            else
            {
                IsTeamOwnerHiddenField.Value = "true";
            }

        }

        protected bool PrivateNoteVisible(object Note)
        {
            if ((Note.ToString().Length == 0) || (IsTeamOwnerHiddenField.Value == "false"))
                return false;
            return true;
        }

        //private void SwitchAscDescHiddenFieldValues()
        //{
        //    if (this.SortAscDescHiddenField.Value == "ASC")
        //        this.SortAscDescHiddenField.Value = "DESC";
        //    else
        //        this.SortAscDescHiddenField.Value = "ASC";
        //}

        //protected void SortByPlayer(Object sender, EventArgs e)
        //{
        //    OnlineUser ou = (OnlineUser)Session["User"];
        //    this.TeamListOfPlayersSqlDataSource.SelectParameters.Clear();
        //    this.TeamListOfPlayersSqlDataSource.SelectParameters.Add("TeamId", TeamId);
        //    this.TeamListOfPlayersSqlDataSource.SelectParameters.Add("Language", ou.Language);
        //    if (this.SortByHiddenField.Value == "Player")
        //    {
        //        SwitchAscDescHiddenFieldValues();
        //        this.TeamListOfPlayersSqlDataSource.SelectParameters.Add("OrderBy", "Player");
        //        this.TeamListOfPlayersSqlDataSource.SelectParameters.Add("OrderASC", this.SortAscDescHiddenField.Value);
        //    }
        //    else
        //    {
        //        this.SortByHiddenField.Value = "Player";
        //        this.TeamListOfPlayersSqlDataSource.SelectParameters.Add("OrderBy", "Player");
        //        this.SortAscDescHiddenField.Value = "DESC";
        //        this.TeamListOfPlayersSqlDataSource.SelectParameters.Add("OrderASC", "DESC");
        //    }
        //    this.PlayersGridView.DataBind();
        //}

        //protected void SortByFitness(Object sender, EventArgs e)
        //{
        //    OnlineUser ou = (OnlineUser)Session["User"];
        //    this.TeamListOfPlayersSqlDataSource.SelectParameters.Clear();
        //    this.TeamListOfPlayersSqlDataSource.SelectParameters.Add("TeamId", TeamId);
        //    this.TeamListOfPlayersSqlDataSource.SelectParameters.Add("Language", ou.Language);
        //    if (this.SortByHiddenField.Value == "Fitness")
        //    {
        //        SwitchAscDescHiddenFieldValues();
        //        this.TeamListOfPlayersSqlDataSource.SelectParameters.Add("OrderBy", "Fitness");
        //        this.TeamListOfPlayersSqlDataSource.SelectParameters.Add("OrderASC", this.SortAscDescHiddenField.Value);
        //    }
        //    else
        //    {
        //        this.SortByHiddenField.Value = "Fitness";
        //        this.TeamListOfPlayersSqlDataSource.SelectParameters.Add("OrderBy", "Fitness");
        //        this.SortAscDescHiddenField.Value = "DESC";
        //        this.TeamListOfPlayersSqlDataSource.SelectParameters.Add("OrderASC", "DESC");
        //    }
        //    this.PlayersGridView.DataBind();
        //}

        //protected void SortByCharisma(Object sender, EventArgs e)
        //{
        //    OnlineUser ou = (OnlineUser)Session["User"];
        //    this.TeamListOfPlayersSqlDataSource.SelectParameters.Clear();
        //    this.TeamListOfPlayersSqlDataSource.SelectParameters.Add("TeamId", TeamId);
        //    this.TeamListOfPlayersSqlDataSource.SelectParameters.Add("Language", ou.Language);
        //    if (this.SortByHiddenField.Value == "Charisma")
        //    {
        //        SwitchAscDescHiddenFieldValues();
        //        this.TeamListOfPlayersSqlDataSource.SelectParameters.Add("OrderBy", "Charisma");
        //        this.TeamListOfPlayersSqlDataSource.SelectParameters.Add("OrderASC", this.SortAscDescHiddenField.Value);
        //    }
        //    else
        //    {
        //        this.SortByHiddenField.Value = "Charisma";
        //        this.TeamListOfPlayersSqlDataSource.SelectParameters.Add("OrderBy", "Charisma");
        //        this.SortAscDescHiddenField.Value = "DESC";
        //        this.TeamListOfPlayersSqlDataSource.SelectParameters.Add("OrderASC", "DESC");
        //    }
        //    this.PlayersGridView.DataBind();
        //}

        //protected void SortByExperience(Object sender, EventArgs e)
        //{
        //    OnlineUser ou = (OnlineUser)Session["User"];
        //    this.TeamListOfPlayersSqlDataSource.SelectParameters.Clear();
        //    this.TeamListOfPlayersSqlDataSource.SelectParameters.Add("TeamId", TeamId);
        //    this.TeamListOfPlayersSqlDataSource.SelectParameters.Add("Language", ou.Language);
        //    if (this.SortByHiddenField.Value == "Experience")
        //    {
        //        SwitchAscDescHiddenFieldValues();
        //        this.TeamListOfPlayersSqlDataSource.SelectParameters.Add("OrderBy", "Experience");
        //        this.TeamListOfPlayersSqlDataSource.SelectParameters.Add("OrderASC", this.SortAscDescHiddenField.Value);
        //    }
        //    else
        //    {
        //        this.SortByHiddenField.Value = "Experience";
        //        this.TeamListOfPlayersSqlDataSource.SelectParameters.Add("OrderBy", "Experience");
        //        this.SortAscDescHiddenField.Value = "DESC";
        //        this.TeamListOfPlayersSqlDataSource.SelectParameters.Add("OrderASC", "DESC");
        //    }
        //    this.PlayersGridView.DataBind();
        //}

        //protected void SortByStrongFoot(Object sender, EventArgs e)
        //{
        //    OnlineUser ou = (OnlineUser)Session["User"];
        //    this.TeamListOfPlayersSqlDataSource.SelectParameters.Clear();
        //    this.TeamListOfPlayersSqlDataSource.SelectParameters.Add("TeamId", TeamId);
        //    this.TeamListOfPlayersSqlDataSource.SelectParameters.Add("Language", ou.Language);
        //    if (this.SortByHiddenField.Value == "StrongFoot")
        //    {
        //        SwitchAscDescHiddenFieldValues();
        //        this.TeamListOfPlayersSqlDataSource.SelectParameters.Add("OrderBy", "StrongFoot");
        //        this.TeamListOfPlayersSqlDataSource.SelectParameters.Add("OrderASC", this.SortAscDescHiddenField.Value);
        //    }
        //    else
        //    {
        //        this.SortByHiddenField.Value = "StrongFoot";
        //        this.TeamListOfPlayersSqlDataSource.SelectParameters.Add("OrderBy", "StrongFoot");
        //        this.SortAscDescHiddenField.Value = "DESC";
        //        this.TeamListOfPlayersSqlDataSource.SelectParameters.Add("OrderASC", "DESC");
        //    }
        //    this.PlayersGridView.DataBind();
        //}

        //protected void SortByInstincts(Object sender, EventArgs e)
        //{
        //    OnlineUser ou = (OnlineUser)Session["User"];
        //    this.TeamListOfPlayersSqlDataSource.SelectParameters.Clear();
        //    this.TeamListOfPlayersSqlDataSource.SelectParameters.Add("TeamId", TeamId);
        //    this.TeamListOfPlayersSqlDataSource.SelectParameters.Add("Language", ou.Language);
        //    if (this.SortByHiddenField.Value == "Instincts")
        //    {
        //        SwitchAscDescHiddenFieldValues();
        //        this.TeamListOfPlayersSqlDataSource.SelectParameters.Add("OrderBy", "Instincts");
        //        this.TeamListOfPlayersSqlDataSource.SelectParameters.Add("OrderASC", this.SortAscDescHiddenField.Value);
        //    }
        //    else
        //    {
        //        this.SortByHiddenField.Value = "Instincts";
        //        this.TeamListOfPlayersSqlDataSource.SelectParameters.Add("OrderBy", "Instincts");
        //        this.SortAscDescHiddenField.Value = "DESC";
        //        this.TeamListOfPlayersSqlDataSource.SelectParameters.Add("OrderASC", "DESC");
        //    }
        //    this.PlayersGridView.DataBind();
        //}
        //protected void SortByGoalKeeping(Object sender, EventArgs e)
        //{
        //    OnlineUser ou = (OnlineUser)Session["User"];
        //    this.TeamListOfPlayersSqlDataSource.SelectParameters.Clear();
        //    this.TeamListOfPlayersSqlDataSource.SelectParameters.Add("TeamId", TeamId);
        //    this.TeamListOfPlayersSqlDataSource.SelectParameters.Add("Language", ou.Language);
        //    if (this.SortByHiddenField.Value == "GoalKeeping")
        //    {
        //        SwitchAscDescHiddenFieldValues();
        //        this.TeamListOfPlayersSqlDataSource.SelectParameters.Add("OrderBy", "GoalKeeping");
        //        this.TeamListOfPlayersSqlDataSource.SelectParameters.Add("OrderASC", this.SortAscDescHiddenField.Value);
        //    }
        //    else
        //    {
        //        this.SortByHiddenField.Value = "GoalKeeping";
        //        this.TeamListOfPlayersSqlDataSource.SelectParameters.Add("OrderBy", "GoalKeeping");
        //        this.SortAscDescHiddenField.Value = "DESC";
        //        this.TeamListOfPlayersSqlDataSource.SelectParameters.Add("OrderASC", "DESC");
        //    }
        //    this.PlayersGridView.DataBind();
        //}

        //protected void SortByPositioning(Object sender, EventArgs e)
        //{
        //    OnlineUser ou = (OnlineUser)Session["User"];
        //    this.TeamListOfPlayersSqlDataSource.SelectParameters.Clear();
        //    this.TeamListOfPlayersSqlDataSource.SelectParameters.Add("TeamId", TeamId);
        //    this.TeamListOfPlayersSqlDataSource.SelectParameters.Add("Language", ou.Language);
        //    if (this.SortByHiddenField.Value == "Positioning")
        //    {
        //        SwitchAscDescHiddenFieldValues();
        //        this.TeamListOfPlayersSqlDataSource.SelectParameters.Add("OrderBy", "Positioning");
        //        this.TeamListOfPlayersSqlDataSource.SelectParameters.Add("OrderASC", this.SortAscDescHiddenField.Value);
        //    }
        //    else
        //    {
        //        this.SortByHiddenField.Value = "Positioning";
        //        this.TeamListOfPlayersSqlDataSource.SelectParameters.Add("OrderBy", "Positioning");
        //        this.SortAscDescHiddenField.Value = "DESC";
        //        this.TeamListOfPlayersSqlDataSource.SelectParameters.Add("OrderASC", "DESC");
        //    }
        //    this.PlayersGridView.DataBind();
        //}
        //protected void SortByStamina(Object sender, EventArgs e)
        //{
        //    OnlineUser ou = (OnlineUser)Session["User"];
        //    this.TeamListOfPlayersSqlDataSource.SelectParameters.Clear();
        //    this.TeamListOfPlayersSqlDataSource.SelectParameters.Add("TeamId", TeamId);
        //    this.TeamListOfPlayersSqlDataSource.SelectParameters.Add("Language", ou.Language);
        //    if (this.SortByHiddenField.Value == "Stamina")
        //    {
        //        SwitchAscDescHiddenFieldValues();
        //        this.TeamListOfPlayersSqlDataSource.SelectParameters.Add("OrderBy", "Stamina");
        //        this.TeamListOfPlayersSqlDataSource.SelectParameters.Add("OrderASC", this.SortAscDescHiddenField.Value);
        //    }
        //    else
        //    {
        //        this.SortByHiddenField.Value = "Stamina";
        //        this.TeamListOfPlayersSqlDataSource.SelectParameters.Add("OrderBy", "Stamina");
        //        this.SortAscDescHiddenField.Value = "DESC";
        //        this.TeamListOfPlayersSqlDataSource.SelectParameters.Add("OrderASC", "DESC");
        //    }
        //    this.PlayersGridView.DataBind();
        //}
        //protected void SortByPower(Object sender, EventArgs e)
        //{
        //    OnlineUser ou = (OnlineUser)Session["User"];
        //    this.TeamListOfPlayersSqlDataSource.SelectParameters.Clear();
        //    this.TeamListOfPlayersSqlDataSource.SelectParameters.Add("TeamId", TeamId);
        //    this.TeamListOfPlayersSqlDataSource.SelectParameters.Add("Language", ou.Language);
        //    if (this.SortByHiddenField.Value == "Power")
        //    {
        //        SwitchAscDescHiddenFieldValues();
        //        this.TeamListOfPlayersSqlDataSource.SelectParameters.Add("OrderBy", "Power");
        //        this.TeamListOfPlayersSqlDataSource.SelectParameters.Add("OrderASC", this.SortAscDescHiddenField.Value);
        //    }
        //    else
        //    {
        //        this.SortByHiddenField.Value = "Power";
        //        this.TeamListOfPlayersSqlDataSource.SelectParameters.Add("OrderBy", "Power");
        //        this.SortAscDescHiddenField.Value = "DESC";
        //        this.TeamListOfPlayersSqlDataSource.SelectParameters.Add("OrderASC", "DESC");
        //    }
        //    this.PlayersGridView.DataBind();
        //}
        //protected void SortByTackling(Object sender, EventArgs e)
        //{
        //    OnlineUser ou = (OnlineUser)Session["User"];
        //    this.TeamListOfPlayersSqlDataSource.SelectParameters.Clear();
        //    this.TeamListOfPlayersSqlDataSource.SelectParameters.Add("TeamId", TeamId);
        //    this.TeamListOfPlayersSqlDataSource.SelectParameters.Add("Language", ou.Language);
        //    if (this.SortByHiddenField.Value == "Tackling")
        //    {
        //        SwitchAscDescHiddenFieldValues();
        //        this.TeamListOfPlayersSqlDataSource.SelectParameters.Add("OrderBy", "Tackling");
        //        this.TeamListOfPlayersSqlDataSource.SelectParameters.Add("OrderASC", this.SortAscDescHiddenField.Value);
        //    }
        //    else
        //    {
        //        this.SortByHiddenField.Value = "Tackling";
        //        this.TeamListOfPlayersSqlDataSource.SelectParameters.Add("OrderBy", "Tackling");
        //        this.SortAscDescHiddenField.Value = "DESC";
        //        this.TeamListOfPlayersSqlDataSource.SelectParameters.Add("OrderASC", "DESC");
        //    }
        //    this.PlayersGridView.DataBind();
        //}
        //protected void SortByHeading(Object sender, EventArgs e)
        //{
        //    OnlineUser ou = (OnlineUser)Session["User"];
        //    this.TeamListOfPlayersSqlDataSource.SelectParameters.Clear();
        //    this.TeamListOfPlayersSqlDataSource.SelectParameters.Add("TeamId", TeamId);
        //    this.TeamListOfPlayersSqlDataSource.SelectParameters.Add("Language", ou.Language);
        //    if (this.SortByHiddenField.Value == "Heading")
        //    {
        //        SwitchAscDescHiddenFieldValues();
        //        this.TeamListOfPlayersSqlDataSource.SelectParameters.Add("OrderBy", "Heading");
        //        this.TeamListOfPlayersSqlDataSource.SelectParameters.Add("OrderASC", this.SortAscDescHiddenField.Value);
        //    }
        //    else
        //    {
        //        this.SortByHiddenField.Value = "Heading";
        //        this.TeamListOfPlayersSqlDataSource.SelectParameters.Add("OrderBy", "Heading");
        //        this.SortAscDescHiddenField.Value = "DESC";
        //        this.TeamListOfPlayersSqlDataSource.SelectParameters.Add("OrderASC", "DESC");
        //    }
        //    this.PlayersGridView.DataBind();
        //}
        //protected void SortByQuickness(Object sender, EventArgs e)
        //{
        //    OnlineUser ou = (OnlineUser)Session["User"];
        //    this.TeamListOfPlayersSqlDataSource.SelectParameters.Clear();
        //    this.TeamListOfPlayersSqlDataSource.SelectParameters.Add("TeamId", TeamId);
        //    this.TeamListOfPlayersSqlDataSource.SelectParameters.Add("Language", ou.Language);
        //    if (this.SortByHiddenField.Value == "Quickness")
        //    {
        //        SwitchAscDescHiddenFieldValues();
        //        this.TeamListOfPlayersSqlDataSource.SelectParameters.Add("OrderBy", "Quickness");
        //        this.TeamListOfPlayersSqlDataSource.SelectParameters.Add("OrderASC", this.SortAscDescHiddenField.Value);
        //    }
        //    else
        //    {
        //        this.SortByHiddenField.Value = "Quickness";
        //        this.TeamListOfPlayersSqlDataSource.SelectParameters.Add("OrderBy", "Quickness");
        //        this.SortAscDescHiddenField.Value = "DESC";
        //        this.TeamListOfPlayersSqlDataSource.SelectParameters.Add("OrderASC", "DESC");
        //    }
        //    this.PlayersGridView.DataBind();
        //}
        //protected void SortByTechnique(Object sender, EventArgs e)
        //{
        //    OnlineUser ou = (OnlineUser)Session["User"];
        //    this.TeamListOfPlayersSqlDataSource.SelectParameters.Clear();
        //    this.TeamListOfPlayersSqlDataSource.SelectParameters.Add("TeamId", TeamId);
        //    this.TeamListOfPlayersSqlDataSource.SelectParameters.Add("Language", ou.Language);
        //    if (this.SortByHiddenField.Value == "Technique")
        //    {
        //        SwitchAscDescHiddenFieldValues();
        //        this.TeamListOfPlayersSqlDataSource.SelectParameters.Add("OrderBy", "Technique");
        //        this.TeamListOfPlayersSqlDataSource.SelectParameters.Add("OrderASC", this.SortAscDescHiddenField.Value);
        //    }
        //    else
        //    {
        //        this.SortByHiddenField.Value = "Technique";
        //        this.TeamListOfPlayersSqlDataSource.SelectParameters.Add("OrderBy", "Technique");
        //        this.SortAscDescHiddenField.Value = "DESC";
        //        this.TeamListOfPlayersSqlDataSource.SelectParameters.Add("OrderASC", "DESC");
        //    }
        //    this.PlayersGridView.DataBind();
        //}
        //protected void SortByShortPassing(Object sender, EventArgs e)
        //{
        //    OnlineUser ou = (OnlineUser)Session["User"];
        //    this.TeamListOfPlayersSqlDataSource.SelectParameters.Clear();
        //    this.TeamListOfPlayersSqlDataSource.SelectParameters.Add("TeamId", TeamId);
        //    this.TeamListOfPlayersSqlDataSource.SelectParameters.Add("Language", ou.Language);
        //    if (this.SortByHiddenField.Value == "ShortPassing")
        //    {
        //        SwitchAscDescHiddenFieldValues();
        //        this.TeamListOfPlayersSqlDataSource.SelectParameters.Add("OrderBy", "ShortPassing");
        //        this.TeamListOfPlayersSqlDataSource.SelectParameters.Add("OrderASC", this.SortAscDescHiddenField.Value);
        //    }
        //    else
        //    {
        //        this.SortByHiddenField.Value = "ShortPassing";
        //        this.TeamListOfPlayersSqlDataSource.SelectParameters.Add("OrderBy", "ShortPassing");
        //        this.SortAscDescHiddenField.Value = "DESC";
        //        this.TeamListOfPlayersSqlDataSource.SelectParameters.Add("OrderASC", "DESC");
        //    }
        //    this.PlayersGridView.DataBind();
        //}
        //protected void SortByLongPassing(Object sender, EventArgs e)
        //{
        //    OnlineUser ou = (OnlineUser)Session["User"];
        //    this.TeamListOfPlayersSqlDataSource.SelectParameters.Clear();
        //    this.TeamListOfPlayersSqlDataSource.SelectParameters.Add("TeamId", TeamId);
        //    this.TeamListOfPlayersSqlDataSource.SelectParameters.Add("Language", ou.Language);
        //    if (this.SortByHiddenField.Value == "LongPassing")
        //    {
        //        SwitchAscDescHiddenFieldValues();
        //        this.TeamListOfPlayersSqlDataSource.SelectParameters.Add("OrderBy", "LongPassing");
        //        this.TeamListOfPlayersSqlDataSource.SelectParameters.Add("OrderASC", this.SortAscDescHiddenField.Value);
        //    }
        //    else
        //    {
        //        this.SortByHiddenField.Value = "LongPassing";
        //        this.TeamListOfPlayersSqlDataSource.SelectParameters.Add("OrderBy", "LongPassing");
        //        this.SortAscDescHiddenField.Value = "DESC";
        //        this.TeamListOfPlayersSqlDataSource.SelectParameters.Add("OrderASC", "DESC");
        //    }
        //    this.PlayersGridView.DataBind();
        //}
        //protected void SortByShooting(Object sender, EventArgs e)
        //{
        //    OnlineUser ou = (OnlineUser)Session["User"];
        //    this.TeamListOfPlayersSqlDataSource.SelectParameters.Clear();
        //    this.TeamListOfPlayersSqlDataSource.SelectParameters.Add("TeamId", TeamId);
        //    this.TeamListOfPlayersSqlDataSource.SelectParameters.Add("Language", ou.Language);
        //    if (this.SortByHiddenField.Value == "Shooting")
        //    {
        //        SwitchAscDescHiddenFieldValues();
        //        this.TeamListOfPlayersSqlDataSource.SelectParameters.Add("OrderBy", "Shooting");
        //        this.TeamListOfPlayersSqlDataSource.SelectParameters.Add("OrderASC", this.SortAscDescHiddenField.Value);
        //    }
        //    else
        //    {
        //        this.SortByHiddenField.Value = "Shooting";
        //        this.TeamListOfPlayersSqlDataSource.SelectParameters.Add("OrderBy", "Shooting");
        //        this.SortAscDescHiddenField.Value = "DESC";
        //        this.TeamListOfPlayersSqlDataSource.SelectParameters.Add("OrderASC", "DESC");
        //    }
        //    this.PlayersGridView.DataBind();
        //}
        //protected void SortByAge(Object sender, EventArgs e)
        //{
        //    OnlineUser ou = (OnlineUser)Session["User"];
        //    this.TeamListOfPlayersSqlDataSource.SelectParameters.Clear();
        //    this.TeamListOfPlayersSqlDataSource.SelectParameters.Add("TeamId", TeamId);
        //    this.TeamListOfPlayersSqlDataSource.SelectParameters.Add("Language", ou.Language);
        //    if (this.SortByHiddenField.Value == "Age")
        //    {
        //        SwitchAscDescHiddenFieldValues();
        //        this.TeamListOfPlayersSqlDataSource.SelectParameters.Add("OrderBy", "Age");
        //        this.TeamListOfPlayersSqlDataSource.SelectParameters.Add("OrderASC", this.SortAscDescHiddenField.Value);
        //    }
        //    else
        //    {
        //        this.SortByHiddenField.Value = "Age";
        //        this.TeamListOfPlayersSqlDataSource.SelectParameters.Add("OrderBy", "Age");
        //        this.SortAscDescHiddenField.Value = "ASC";
        //        this.TeamListOfPlayersSqlDataSource.SelectParameters.Add("OrderASC", "ASC");
        //    }
        //    this.PlayersGridView.DataBind();
        //}
        //protected void SortByShirtNumber(Object sender, EventArgs e)
        //{
        //    OnlineUser ou = (OnlineUser)Session["User"];
        //    this.TeamListOfPlayersSqlDataSource.SelectParameters.Clear();
        //    this.TeamListOfPlayersSqlDataSource.SelectParameters.Add("TeamId", TeamId);
        //    this.TeamListOfPlayersSqlDataSource.SelectParameters.Add("Language", ou.Language);
        //    if (this.SortByHiddenField.Value == "ShirtNum")
        //    {
        //        SwitchAscDescHiddenFieldValues();
        //        this.TeamListOfPlayersSqlDataSource.SelectParameters.Add("OrderBy", "ShirtNum");
        //        this.TeamListOfPlayersSqlDataSource.SelectParameters.Add("OrderASC", this.SortAscDescHiddenField.Value);
        //    }
        //    else
        //    {
        //        this.SortByHiddenField.Value = "ShirtNum";
        //        this.TeamListOfPlayersSqlDataSource.SelectParameters.Add("OrderBy", "ShirtNum");
        //        this.SortAscDescHiddenField.Value = "ASC";
        //        this.TeamListOfPlayersSqlDataSource.SelectParameters.Add("OrderASC", "ASC");
        //    }
        //    this.PlayersGridView.DataBind();
        //}


        protected override void InitializeCulture()
        {
            if (HttpContext.Current.User.Identity.IsAuthenticated)
            {

                OnlineUser ou = (OnlineUser)Session["User"];
                Thread.CurrentThread.CurrentUICulture = new CultureInfo(ou.UICulture);
                Thread.CurrentThread.CurrentCulture = CultureInfo.CreateSpecificCulture(ou.Culture);
            }
        }

        //protected void RefreshGrid(object sender, EventArgs e)
        //{
        //    this.PlayersGridView.DataBind();
        //}

        protected string InjuryIconName(object Injury)
        {
            GetNivdalData.GetNivdalData GND = new GetNivdalData.GetNivdalData();
            return GND.InjuryIconName(Injury);
        }

        

        protected string WarningsSortText(bool Y1, bool Y2, bool red)
        {
            if (red)
                return "0";
            if (Y2)
                return "1";
            if (Y1)
                return "2";
            return "3";            
        }

        protected string ShirtNumberForSort(object ShirtNumber)
        {
            if (ShirtNumber == null)
                return "0";
            decimal Num;
            if (Decimal.TryParse(ShirtNumber.ToString(), out Num))
                return (Num + 100).ToString();
            return "0";
        }

        protected string FirstTwoLetters(object String)
        {
            try
            {
                return (String.ToString().Substring(0, 2));
            }
            catch { }
            try
            {
                return (String.ToString().Substring(0, 1));
            }
            catch { }
            return "0";
        }
        //protected void CompareSelected(object sender, EventArgs e)
        //{
        //    GetNivdalData.GetNivdalData GND = new GetNivdalData.GetNivdalData();
        //    string UserId = GND.ReturnUserId();
        //    string PlayerId;

        //    // delete all previous selections
        //    GND.ExecNivdalSQL("UserId", "Nivdal_InitPlayerCompareForUser", UserId);

        //    // insert all new selections
        //    foreach (GridViewRow row in PlayersGridView.Rows)
        //    {
        //        PlayerId = (row.FindControl("PlayerIdHiddenField") as HiddenField).Value;
        //        GND.ExecNivdalSQL("UserId", "PlayerId", "Nivdal_AddPlayerCompare", UserId, PlayerId);
        //    }

        //    Response.Redirect("Compareplayers.aspx");
        //}
    }

}